package com.wgke.bluetooth.view;


import android.content.Context;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;
import android.util.Log;

public class HeatMap3DView extends GLSurfaceView {
    private HeatMapRenderer renderer;
    private float[][] heatMapData;

    public HeatMap3DView(Context context) {
        super(context);
        init();
    }

    public HeatMap3DView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init() {
        // 设置EGL版本为2（OpenGL ES 2.0）
        setEGLContextClientVersion(2);
        renderer = new HeatMapRenderer(getContext());
        setRenderer(renderer);
        // 设置渲染模式为连续渲染
        setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
    }

    // 设置热力图数据
    public void setHeatMapData(float[][] data) {
        heatMapData = data;
        Log.e("HeatMap3DView","--"+(renderer != null));
        if (renderer != null) {
            renderer.setHeatMapData(heatMapData);
        }
    }
}